// 替换原有导入
// import { post, get } from '../utils/request'

// 模拟请求函数
const mockRequest = (data = {}) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: '0',
        message: 'success',
        ...data
      })
    }, 100)
  })
}

// 定时消息模板相关API
export const timedMsgListAPI = () => {
  return mockRequest({
    data: [
      {
        id: 1,
        templateName: '欢迎新用户',
        content: '欢迎加入我们的平台！',
        status: 1,
        createTime: '2024-01-01 10:00:00'
      },
      {
        id: 2,
        templateName: '活动提醒',
        content: '您关注的活动即将开始',
        status: 0,
        createTime: '2024-01-02 15:30:00'
      }
    ]
  })
}

export const timedMsgAddAPI = (data) => {
  return mockRequest({
    message: '新增成功',
    data: { id: Date.now(), ...data }
  })
}

export const timedMsgEditAPI = (data) => {
  return mockRequest({
    message: '更新成功',
    data: data
  })
}

export const timedMsgDelAPI = (id) => {
  return mockRequest({
    message: '删除成功'
  })
}

// 定时任务相关API
export const timedMsgTaskListAPI = (data) => {
  return mockRequest({
    data: {
      objects: [
        {
          id: 1,
          taskId: 'TASK001',
          templateName: '欢迎新用户',
          sendTime: '2024-01-10 09:00:00',
          status: 1
        }
      ],
      total: 1
    }
  })
}

export const timedMsgTaskAddAPI = (data) => {
  return mockRequest({
    message: '任务创建成功',
    data: { id: Date.now(), ...data }
  })
}

// 触发消息模板相关API
export const triggerMsgListAPI = (data) => {
  return mockRequest({
    data: [
      {
        id: 1,
        msgTitle: '注册成功',
        msgContent: '恭喜您注册成功，欢迎使用我们的服务',
        triggerType: 1,
        status: 1
      },
      {
        id: 2,
        msgTitle: '订单完成',
        msgContent: '您的订单已完成，感谢您的购买',
        triggerType: 2,
        status: 1
      }
    ]
  })
}

export const triggerMsgAddAPI = (data) => {
  return mockRequest({
    message: '新增成功',
    data: { id: Date.now(), ...data }
  })
}

export const triggerMsgEditAPI = (data) => {
  return mockRequest({
    message: '更新成功',
    data: data
  })
}

export const triggerMsgDelAPI = (id) => {
  return mockRequest({
    message: '删除成功'
  })
}

// 动态字段API
export const msgFieldAPI = () => {
  return mockRequest({
    data: [
      { id: 1, fieldName: '用户名', fieldCode: '{username}' },
      { id: 2, fieldName: '订单号', fieldCode: '{orderId}' },
      { id: 3, fieldName: '商品名称', fieldCode: '{productName}' }
    ]
  })
}

// 触发消息API
export const triggerMsgAPI = () => {
  return mockRequest({
    data: [
      { id: 1, name: '用户注册', type: 1 },
      { id: 2, name: '订单完成', type: 2 },
      { id: 3, name: '支付成功', type: 3 }
    ]
  })
}
